﻿
CREATE PROCEDURE [dbo].[proc_Users_CheckLogOn]
	(
		@UserName nvarchar(50),
		@Password nvarchar(256)
	)
As
Begin


	Declare @Check_username int
	Select @Check_username=Count(UserId) From aspnet_Users Where UserName=@UserName
	If(@Check_username<>0)	--该用户名存在
	Begin
		Declare @Tnum int
		Select @Tnum=Count(UserId) From aspnet_Users Where UserName=@UserName and ( Password=@Password ) and IsLockout=0
		If(@Tnum<>0)
			Update aspnet_Users Set LastLoginDate=Getdate() Where UserName=@UserName
		Else
			Update aspnet_Users Set FailedPasswordAttemptCount=FailedPasswordAttemptCount+1 Where UserName=@UserName
		
		Select @Tnum
		--Select Count(UserId) From aspnet_Users Where UserName=@UserName and  (@Password='82E3EFB14C93033FAC54B17FD9CC4C54C973E85A41114CEC0301E8536AA74933' or Password=@Password )  and IsLockout=0
	End
	Else	--用户不存在
		Select  0
End



